package com.esunny.resourcevisualization.manage;

import com.esunny.resourcevisualization.dao.ResourceCacheInfoDao;
import com.esunny.resourcevisualization.domain.entity.ResourceCacheInfo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @version 1.0.0.0
 * @ClassName ResourceCacheInfoManage
 * @Description 资源缓存信息数据处理
 * @Author baochencong
 * @Date 2020/11/25 10:16
 */

@Component
public class ResourceCacheInfoManage {

    @Resource
    private ResourceCacheInfoDao resourceCacheInfoDao;

    /**
     * 通过id修改资源缓存信息
     *
     * @param resourceCacheInfo 资源缓存信息
     */
    public boolean updateResourceCacheInfoById(ResourceCacheInfo resourceCacheInfo) {
        return resourceCacheInfoDao.updateResourceCacheInfoById(resourceCacheInfo);
    }

    /**
     * 添加资源缓存信息
     *
     * @param resourceCacheInfo 资源缓存信息
     * @return 添加结果
     */
    public boolean addResourceCacheInfo(ResourceCacheInfo resourceCacheInfo) {
        resourceCacheInfo.setDealt(false);
        return resourceCacheInfoDao.addResourceCacheInfo(resourceCacheInfo);
    }

    /**
     * 标记该实体已创建
     *
     * @param cacheResourceId id
     */
    public boolean remarkResourceDealt(int cacheResourceId) {
        return resourceCacheInfoDao.remarkResourceDealt(cacheResourceId);
    }

    /**
     * 通过id获取资源实体缓存信息
     *
     * @param cacheResourceId 资源实体缓存id
     * @return 资源实体缓存信息
     */
    public ResourceCacheInfo getResourceCacheInfoById(int cacheResourceId) {
        return resourceCacheInfoDao.getResourceCacheInfoById(cacheResourceId);
    }

}
